//
//  M4ProrrogaDetailCell.swift
//  M4
//
//  Created by YuChuang on 2024/8/28.
//

import UIKit

class M4ProrrogaDetailCell: M4BaseTableViewCell {
    
    @IBOutlet weak var M4ProrrogaDays: UILabel!
    
    @IBOutlet weak var M4ProrrogaAmount: UILabel!
    
    @IBOutlet weak var M4ProrrogaYHAmount: UILabel!
    
    @IBOutlet weak var M4ProrrogaDate: UILabel!
    
    @IBOutlet weak var M4ProrrogaButton: UIButton!
    
    private var prorrogaModel: M4LoanOrderSonDataModel?
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }
    
    override func M4UpdateDataAndUI() {
        prorrogaModel = data as? M4LoanOrderSonDataModel
        M4ProrrogaDays.text = "\(prorrogaModel?.QTbVN ?? 0) Días"
        M4ProrrogaAmount.text = "$\(M4String.M4BlankAmount(original: "\(prorrogaModel?.Fvap ?? 0)"))"
        M4ProrrogaYHAmount.text = "$\(M4String.M4BlankAmount(original: "\(prorrogaModel?.IVkd ?? 0)"))"
        let time = (prorrogaModel?.SMymy ?? 0) / 1000
        let date = Date(timeIntervalSince1970: TimeInterval(time))
        let formatter = DateFormatter()
        formatter.dateFormat = "dd-MM-yyyy"
        let dateString = formatter.string(from: date)
        M4ProrrogaDate.text = prorrogaModel?.WxW7NH ?? ""
        M4ProrrogaButton.backgroundColor = prorrogaModel?.RmNOmNgMClM == 1 ? COLOR_00479D : COLOR_EFEFEF
        M4ProrrogaButton.setTitleColor(prorrogaModel?.RmNOmNgMClM == 1 ? .white : COLOR_666666, for: .normal)
        M4ProrrogaButton.isUserInteractionEnabled = prorrogaModel?.RmNOmNgMClM == 1 ? true : false
    }
    
    @IBAction func M4ProrrogaAction(_ sender: UIButton) {
        M4CellActionDelegate?.M4CellAction(M4IDAction(actionType: M4PagoAction.M4ProrrogaAction.rawValue, actionData: ""))
        sender.M4EventUnavailable = false
    }
    
    override func M4CellLeftRightEdge() -> CGFloat {
        return 0
    }
}
